Fix ImportError: use Django's cached_property instead of cryptography's - #46
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
alexlambson
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
The production site (
mapdb2.cncnet.org) returned HTTP 500 on every route:The failure happens while Django loads the root URLconf, so no URL resolves at all — this is not limited to the upload endpoints, despite the module name.
cryptography.utils.cached_propertywas a private, undocumented shim that has since been removed upstream. The server had resolvedcryptography==50.0.0, where it no longer exists.Critically:
cryptographyis not a declared dependency of this project. It is absent fromrequirements.txtand arrives transitively, unpinned, viapyjwt[crypto]. The code was reaching into a private API of a package it never asked for, so a routine image rebuild broke production with no code change on our side.The fix
Two occurrences, import line only. Replace:
with:
in
kirovy/services/legacy_upload/base.pyandkirovy/views/map_upload_views.py.Why this is safe
django.utils.functional.cached_propertyis a true drop-in here:__dict__.__slots__appears nowhere in the codebase, so the descriptor can write its cache.user_log_attrsinmap_upload_views.py;expected_files,map_sha1_from_filename,file_contents_merged,map_nameinbase.py).expected_filesis a@cached_propertyin the base class that raisesNotImplementedErrorand is overridden in subclasses — this pattern works identically under Django's implementation.cryptographyreference remains in any.pyfile, and both files passpython -m py_compile.Pinning
cryptographyto an older version was rejected: it papers over the problem and leaves the project depending on a private API of an undeclared transitive dependency.Optional follow-ups (not bundled here)
requirements.txtshould pin anything it imports directly.cryptographyonly viapyjwt[crypto]; nothing else uses it.🤖 Generated with Claude Code